-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make all post-processing conditional #2173
base: master
Are you sure you want to change the base?
Conversation
I like the idea, but:
|
Thanks for the response
I thought all nonzero values were true for convars. I thought it would be simpler this way.
Thank you for considering this, that's a very important oversight.
Good idea. Thanks. |
The function to draw the bloom (called from the hook) | ||
-----------------------------------------------------------]] | ||
hook.Add( "RenderScreenspaceEffects", "RenderBloom", function() | ||
cvars.AddChangeCallback( "pp_bloom", function( _, _, newValue ) | ||
|
||
-- No bloom for crappy gpus | ||
|
||
if ( !render.SupportsPixelShaders_2_0() ) then return end | ||
if ( !pp_bloom:GetBool() ) then return end | ||
if ( !GAMEMODE:PostProcessPermitted( "bloom" ) ) then return end | ||
|
||
DrawBloom( pp_bloom_darken:GetFloat(), pp_bloom_multiply:GetFloat(), | ||
if ( newValue != "0" ) then | ||
hook.Add( "RenderScreenspaceEffects", "RenderBloom", function() | ||
|
||
DrawBloom( pp_bloom_darken:GetFloat(), pp_bloom_multiply:GetFloat(), | ||
pp_bloom_sizex:GetFloat(), pp_bloom_sizey:GetFloat(), | ||
pp_bloom_passes:GetFloat(), pp_bloom_color:GetFloat(), | ||
pp_bloom_color_r:GetFloat() / 255, pp_bloom_color_g:GetFloat() / 255, pp_bloom_color_b:GetFloat() / 255 ) | ||
|
||
end) | ||
else | ||
hook.Remove( "RenderScreenspaceEffects", "RenderBloom" ) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing it this way introduces a regression where the result of GAMEMODE:PostProcessPermitted
is not updated live.
I can understand SupportsPixelShaders_2_0
being a static thing and can be moved outside of the hook.
I also think it's a better idea to make a the hook a local function and reference that in the cvars.AddChangeCallback
callback, rather than nesting functions like this.
@@ -113,4 +117,4 @@ list.Set( "PostProcess", "#bloom_pp", { | |||
|
|||
end | |||
|
|||
} ) | |||
} ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary change.
|
||
DOF_SPACING = pp_dof_spacing:GetFloat() | ||
DOF_OFFSET = pp_dof_initlength:GetFloat() | ||
end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary change that does not conform to the style guidelines:
https://github.com/Facepunch/garrysmod/blob/master/CONTRIBUTING.md
|
||
cvars.AddChangeCallback( "pp_fb", function( _, _, newValue ) | ||
|
||
if ( !GAMEMODE:PostProcessPermitted( "fb" ) ) then return end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "frame_blend"
, not "fb"
|
||
if ( !frame_blend.IsActive() ) then return end | ||
if ( !frame_blend.IsActive() ) then hook.Remove( "RenderFrameBlend", "RenderFrameBlend" ) return end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary?
|
||
vgui.GetWorldPanel():MouseCapture( false ) | ||
FocusGrabber = false | ||
end ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire file is a mess. See previous comments.
I also think this can be all done better, such as removing the hooks from Panel.OnRemove
of the SuperDOFWindow
for example.
Optimizes post-processing by not having their hooks run when they're never used. Also removes some unnecessary checks or moves them to run only once.
Now post-processing hooks run only when needed.
I tested it and it all works fine, but I would appreciate anyone looking over this to make sure I didn't do any copying errors.
Was waiting for someone else to do this before I realized it'd be faster to do it myself.